﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ZhuanHuanZLSGSSJ.aspx.cs" Inherits="Web.Pages.YongShui.ChaoBiaoKZ.ZhuanHuanZLSGSSJ" Theme="Default" %>

<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>



<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../../../JS/jquery.js"></script>
    <script src="../../../JS/AddEditCancel.js"></script>
    <style type="text/css">
        .left {
            text-align: left;
        }

        .center {
            text-align: center;
        }

        .right {
            text-align: right;
        }

        table {
        }
    </style>
    <style type="text/css">
        textarea {
            font-size: 16px !important;
        }
    </style>
    <script type="text/javascript">

        var typenum = 1;
        //开始上传文件
        function Uploader_OnUploadStart() {
            //验证文件类型
            LoadPanel.Show();

        }
        var times = 0;
        //文件上传完成,并显示图片预览
        function Uploader_OnFileUploadComplete(args) {
            if (args.isValid) {


                //alert(args.callbackData);
                if (parseInt(args.callbackData) < 0) {
                    alert('文件上传失败');
                    LoadPanel.Hide();
                    //alert(typenum);
                    //if (typenum == 1) {
                    //    ZhuanHuanSJ();
                    //}
                    //else {
                    //    ZhuanHuanLSSJ();
                    //}
                }
                else {
                    //txtZhuanHuanJG.SetText(txtZhuanHuanJG.GetText() + args.callbackData);
                    if (times == 0) {
                        Call.PerformCallback("zhsj");
                    }
                    times++;
                }


            }
        }
        function CheckZH(type) {
            if (uploader.GetText() == "") {
                alert("请先选择上传文件");
            }
            else {
                txtZhuanHuanJG.SetText("开始：\r");
                if (type == 0) {
                    HidList.Set("type", 0);
                    typenum = 1;
                    uploader.Upload();
                }
                else {
                    HidList.Set("type", 1);
                    typenum = 2;
                    uploader.Upload();
                }
            }
        }
        function ChangeCount() {
            alert(1);
        }
        function OpenCWXX() {
            var url = "ZhuanHuanCWXX.aspx";
            openCenter(url, "800px", "500px");
        }
        function ZhuanHuanSJ() {
            Call.PerformCallback("zhuanhuansjcheck");
        }
        function ZhuanHuanLSSJ() {
            Call.PerformCallback("zhuanhuanlssjcheck");
        }
        function CallBackFunction(rs) {
            //alert(rs);
            var list = rs.split('|');
            var key = list[0];
            var code = list[1];
            var msg = list[2];
            if (key == "zhuanhuansjcheck") {
                if (code > 0) {
                    LoadPanel.Show();
                    BtnZH.onClick();
                }
                else {
                    alert(msg);
                }
            }
            if (key == "zhuanhuanlssjcheck") {
                if (code > 0) {
                    LoadPanel.Show();
                    BtnZHLS.onClick();
                }
                else {
                    alert(msg);
                }
            }
            if (key == "zhsj") {
               
                txtZhuanHuanJG.SetText(txtZhuanHuanJG.GetText() + msg);
                if (code > 0) {                    
                    
                    Call.PerformCallback("zhsj");

                }
                else {
                    txtZhuanHuanJG.SetText(txtZhuanHuanJG.GetText() + "结束");
                    LoadPanel.Hide();
                    times = 0;
                    //将地下水关联抄表数据存入中间表QS_SJHGCBSJ
                    Call.PerformCallback("cbsj_dxs");
                }
            }
        }
    </script>
    <style type="text/css">
        li {
         float:left;
          margin-left:10px;
         width:100px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <dx:ASPxHiddenField ID="HidList" ClientInstanceName="HidList" runat="server"></dx:ASPxHiddenField>

        <dx:ASPxCallback ID="Call" ClientInstanceName="Call" OnCallback="Call_Callback" ClientSideEvents-CallbackComplete="function(s,e){CallBackFunction(e.result);}" runat="server"></dx:ASPxCallback>
        <div class="tabletitle1" align="center">
            转换自来水公司数据
        </div>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div style="border: 0px solid #4486a9; width: 99%; overflow:auto" class="left">
                    <dx:ASPxLabel ID="lblNianYue" runat="server" Text=""></dx:ASPxLabel>
                    <%--<a href="/UPLOAD/Silverlight_5.1.50428.0.exe" target="_blank">插件</a>--%>
                    <table>
                        <tr style=" height:30px">
                            <td valign="top" style="padding-top:10px; min-width:80px">选择文件：
                              
                            </td>
                        
                            <td valign="top" rowspan="2">
                                <dx:ASPxUploadControl ID="UpLoadFile" runat="server" ClientInstanceName="uploader"   
                                    NullText="请选择文件" ShowTextBox="false"    
                                    ShowClearFileSelectionButton="false" Theme="Aqua1" UploadMode="Standard" OnFileUploadComplete="UpLoadFile_FileUploadComplete"
                                    Width="100%">
                                    <BrowseButton Text="选择文件"></BrowseButton>
                                    <RemoveButton Text="移除" ></RemoveButton>
                                    
                                    <AdvancedModeSettings EnableFileList="true"  EnableMultiSelect="true"></AdvancedModeSettings>
                                    <ClientSideEvents    FileUploadStart="function(s, e) { Uploader_OnUploadStart(); }"
                                        FileUploadComplete="function(s, e) { Uploader_OnFileUploadComplete(e); }"></ClientSideEvents>
                                    <ValidationSettings AllowedFileExtensions=".dbf" MaxFileSizeErrorText="251200000" NotAllowedFileExtensionErrorText="只能上传DBF文件">
                                    </ValidationSettings>
                                </dx:ASPxUploadControl>
                            </td>
                            
                        </tr>
                       
                    </table>
                    
                </div>
                <br />
                <div runat="server" id="divWenJianGZ" visible="false">
                    <fieldset style="border: 1px solid  cornflowerblue">
                        <legend style="font-weight: bold">采集情况</legend>
                        <dx:ASPxGridView ID="gvWenJianGZ" runat="server" AutoGenerateColumns="False" KeyFieldName="S_MINGCHENG" Theme="Aqua1" Width="100%">
                            <Columns>
                                <dx:GridViewDataTextColumn FieldName="S_MINGCHENG" Caption="名称" Width="12.5%" HeaderStyle-HorizontalAlign="Center"></dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_GUANLIKBH" Caption="所属区块" Width="12.5%" HeaderStyle-HorizontalAlign="Center"></dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="I_YM" Caption="年月" Width="10%" HeaderStyle-HorizontalAlign="Center"></dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_GUANLIKMC" Caption="区块名称" Width="12.5%" HeaderStyle-HorizontalAlign="Center"></dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_GONGSIMC" Caption="所属公司" Width="17%" HeaderStyle-HorizontalAlign="Center"></dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_WENJIANGZ" Caption="文件命名规则" Width="12.5%" HeaderStyle-HorizontalAlign="Center"></dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_CAIJIJG" Caption="结果" Width="10.5%" HeaderStyle-HorizontalAlign="Center"></dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="D_CAIJIRQ" PropertiesTextEdit-DisplayFormatString="{0:yyyy-MM-dd}" Caption="采集日期" Width="12.5%" HeaderStyle-HorizontalAlign="Center"></dx:GridViewDataTextColumn>
                            </Columns>
                            <SettingsPager Mode="ShowAllRecords"></SettingsPager>
                            <Settings VerticalScrollableHeight="450" VerticalScrollBarMode="Auto" />
                        </dx:ASPxGridView>
                    </fieldset>
                </div>
                <div runat="server" id="divZhuanHuanJG" visible="true">
                    <fieldset style="border: 1px solid  cornflowerblue">
                        <legend style="font-weight: bold">转换结果</legend>
                        <dx:ASPxMemo ID="txtZhuanHuanJG" ClientInstanceName="txtZhuanHuanJG" runat="server" Height="450px" Width="100%" ReadOnly="true"></dx:ASPxMemo>
                    </fieldset>
                </div>

                <br />
                <div class="right">
                    <dx:ASPxLoadingPanel ID="LoadPanel" Theme="Metropolis" ClientInstanceName="LoadPanel" runat="server" Modal="True" Text="正在转换..."></dx:ASPxLoadingPanel>
                    <dx:ASPxButton ID="btnZhuanHuanSJ" runat="server" Text="转换数据" AutoPostBack="false"
                        UseSubmitBehavior="false">
                        <ClientSideEvents Click="function(s, e) {  CheckZH(0);}" />
                    </dx:ASPxButton>
                    <dx:ASPxButton ID="btnChaKan" runat="server" Text="查看"
                        UseSubmitBehavior="false" OnClick="btnChaKan_Click">
                        <ClientSideEvents Click="function(s,e){LoadPanel.SetText('正在查询...');LoadPanel.Show();}" />
                    </dx:ASPxButton>
                    <dx:ASPxButton ID="btnZhuanHuanLSSJ" runat="server" Text="转换历史数据" AutoPostBack="false"
                        UseSubmitBehavior="false">
                        <ClientSideEvents Click="function(s, e) {  CheckZH(1);}" />
                    </dx:ASPxButton>
                    <dx:ASPxButton ID="btnChaKanCW" AutoPostBack="false" runat="server" Text="查看错误"
                        UseSubmitBehavior="false">
                        <ClientSideEvents Click="function(s,e){OpenCWXX();}" />
                    </dx:ASPxButton>
                </div>
                <div style="display: none">
                    <dx:ASPxButton ID="btnzh" ClientInstanceName="BtnZH" runat="server" Text="转换数据" OnClick="btnZhuanHuanSJ_Click">
                    </dx:ASPxButton>
                    <dx:ASPxButton ID="ASPxButton1" ClientInstanceName="BtnZHLS" runat="server" Text="转换数据" OnClick="btnZhuanHuanLSSJ_Click">
                    </dx:ASPxButton>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>


